Intermediate CSS Interview Preparation Structure

Level                Type

Intermediate                     Layouts, positioning, pseudo-classes, flexbox, media queries



1. What is the box model in CSS?
Ans:
Every HTML element is a box composed of:
Content → Padding → Border → Margin

2. What is the default position of elements in CSS?
Ans.
By default, most elements have position: static;

3. What is the difference between relative, absolute, and fixed position?
Ans.
  • relative: Positioned relative to its normal position
  • absolute: Positioned relative to the nearest positioned ancestor
  • fixed: Positioned relative to the viewport
4. How to make a div center horizontally?
Ans. 
margin: 0 auto;

5. How to hide an element using CSS?
Ans.
display: none;

6. How do you make a website responsive with CSS?
Ans.
Using media queries:
@media (max-width: 768px) {
    body {
      background-color: lightgray;
    }
  }  

7. What is z-index in CSS?
Ans.
It defines the stack order of elements. Higher z-index appears on top.

8. How do you create a hover effect?
Ans.
button:hover {
    background-color: red;
}

9. How to apply a font from Google Fonts?
Ans.
in html file
html
<link href="https://fonts.googleapis.com/css2?family=Roboto" rel="stylesheet">


in css file
css
body {
    font-family: 'Roboto', sans-serif;
  }
 

10. What are pseudo-classes?
Ans.
They style elements based on their state:
:hover, :focus, :first-child, :last-child, etc.


















































 

Comments

Popular posts from this blog

PHP INTERVIEW QUESTIONS

PHP Intermediate Questions Interview Preparation

PHP Interview Questions (Beginner Level) – Short Answers